import 'package:flutter/material.dart';
import '../pages/Tabs.dart';

import '../pages/Form.dart';
import '../pages/Search.dart';
import '../pages/AppBarDemo.dart';
import '../pages/TabController.dart';
import '../pages/User.dart';
import '../pages/Swiper.dart';
import '../pages/Dialog.dart';

import '../pages/Product.dart';
import '../pages/Button.dart';
import '../pages/ButtonExtend.dart';
import '../pages/TextField.dart';
import '../pages/Checkbox.dart';
import '../pages/Radio.dart';
import '../pages/FormDemo.dart';
import '../pages/DatePicker.dart';
import '../pages/Http.dart';
import '../pages/Refresh.dart';

import '../pages/DatePickerPub.dart';

import '../pages/ProductInfo.dart';
import '../pages/user/Login.dart';
import '../pages/user/RegisterFirst.dart';
import '../pages/user/RegisterSecond.dart';
import '../pages/user/RegisterThird.dart';

final Map<String, Function> routes = {
  '/': (contxt) => Tabs(),
  '/dialog': (contxt) => DialogDemo(),
  '/refresh': (contxt) => RefreshDemo(),
  '/http': (contxt) => HttpDemo(),
  '/form': (context) => FormPage(),
  '/swiper': (context) => SwiperPage(),
  '/datePicker': (context) => DatePickerDemo(),
  '/datePickerPub': (context) => DatePickerPubDemo(),
  '/formDemo': (context) => FormDemoPage(),
  '/radio': (context) => RadioDemo(),
  '/checkbox': (context) => CheckboxDemo(),
  '/textField': (context) => TextFieldPage(),
  '/button': (context) => ButtonDemoPage(),
  '/buttonExtend': (context) => ButtonExtendPage(),
  '/user': (context) => UserPage(),
  '/tabController': (context) => TabControllerPage(),
  '/appBarDemo': (context) => AppBarDemoPage(),
  '/search': (context, {arguments}) => SearchPage(arguments: arguments),
  '/productinfo': (context, {arguments}) =>
      ProductInfoPage(arguments: arguments),
  '/product': (context) => ProductPage(),
  '/login': (context) => LoginPage(),
  '/registerfirst': (context) => RegisterFirstPage(),
  '/registersecond': (context) => RegisterSecondPage(),
  '/registerThird': (context) => RegisterThirdPage(),
};
var onGenerateRoute = (RouteSettings settings) {
  // 统一处理
  final String? name = settings.name;
  final Function pageContentBuilder = routes[name] as Function;
  if (pageContentBuilder != null) {
    if (settings.arguments != null) {
      final Route route = MaterialPageRoute(
          builder: (context) =>
              pageContentBuilder(context, arguments: settings.arguments));
      return route;
    } else {
      final Route route =
          MaterialPageRoute(builder: (context) => pageContentBuilder(context));
      return route;
    }
  }
};
